mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 19:27:36 +00:00
* feat(agent): type-safe CREATION_CONTEXT metadata on create_file/create_version
Build the create_file and create_version tool metadata parameter from the
project's CREATION_CONTEXT fields at harness creation time, instead of the
schemaless key-value map that required the agent to call list_autofill_fields
first.
- Thread projectId from the chat workflow into createAgentSession and build
a strict, all-required (nullable) metadata schema via fieldsToTypeBoxSchema
(additionalProperties: false, option IDs enforced via enum).
- Remove the list_autofill_fields tool and its activity case.
- Reject metadata keys that are not CREATION_CONTEXT fields of the target
project with a clear non-retryable error telling the agent to omit metadata.
- Skip null metadata values when persisting (create_file/create_version and
the autofill workflow).
- Switch the touched schemas from @sinclair/typebox 0.34 to typebox v1 to
match the harness validator.
* refactor(agent): migrate remaining tools from @sinclair/typebox 0.34 to typebox v1
All agent tool schemas now use the same typebox v1 package as the harness
validator; drop the @sinclair/typebox 0.34 dependency from @shumai/agent.
* test(agent): reproduce null coercion in harness tool validation
The pi-ai harness (<=0.82.1) coerces null values in [string, null] unions to
'' during tool argument validation for typebox v1 schemas. A valid create_file
call with path: null + data: {...} therefore arrives at execute with path: ''
and fails with 'Provide exactly one of path or data'. Null metadata values
(the 'unknown' sentinel) are likewise turned into ''.
This test reproduces both failures. It is expected to fail until
@earendil-works/pi-ai is upgraded to >=0.84.0 (#7328), which preserves values
that already match a union arm.
* fix(agent): patch pi-ai 0.82.1 to preserve null in nullable union tool args
Apply the upstream fix for earendil-works/pi#7328 (PR #7373) via a bun
patch instead of upgrading pi-ai. coerceWithUnionSchema now returns the
original value when it already validates against any union member,
instead of coercing null in [string, null] unions into "".
Fixes the create_file false "Provide exactly one of path or data" error
when the model passes path: null with data. Reproduced by
packages/agent/src/reproduce-tool-null-coercion.test.ts, which now passes.
* fix(docker): copy bun patch dir before frozen-lockfile install
The pi-ai patchedDependencies entry makes bun install --frozen-lockfile
fail in the builder stage because patches/ was not present in the image
yet. Copy it alongside package.json/bun.lock so the patch applies.
* refactor(agent): simplify metadata guidance in system prompt and error message
Shorten the create_file/create_version metadata instructions in the system
prompt and reword the invalid-metadata-key error to not reference
CREATION_CONTEXT internals. Update the matching test assertion.
87 lines
2.2 KiB
Docker
87 lines
2.2 KiB
Docker
#syntax=docker/dockerfile:1.7-labs
|
|
# Stage 1: Builder
|
|
FROM oven/bun:1 AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json bun.lock ./
|
|
COPY --parents packages/*/package.json ./
|
|
COPY --parents apps/*/package.json ./
|
|
COPY patches/ ./patches/
|
|
|
|
# Install dependencies (including devDependencies for build tools)
|
|
RUN bun install --frozen-lockfile
|
|
|
|
RUN ls -la packages/transcode/node_modules
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build API and Worker
|
|
RUN bun run build.ts
|
|
|
|
# Generate runner-package.json for the runner stage
|
|
RUN bun run scripts/extract-runtime-deps.ts
|
|
|
|
# Stage 2: Runner
|
|
FROM oven/bun:1 AS runner
|
|
|
|
# Install ffmpeg/ffprobe
|
|
COPY --from=mwader/static-ffmpeg:8.1 /ffmpeg /usr/local/bin/
|
|
COPY --from=mwader/static-ffmpeg:8.1 /ffprobe /usr/local/bin/
|
|
|
|
# Install system dependencies for sandbox runtime and agent
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3 \
|
|
make \
|
|
man-db \
|
|
curl \
|
|
dnsutils \
|
|
less \
|
|
jq \
|
|
bc \
|
|
unzip \
|
|
rsync \
|
|
ripgrep \
|
|
procps \
|
|
lsof \
|
|
socat \
|
|
ca-certificates \
|
|
bubblewrap \
|
|
gosu \
|
|
poppler-utils \
|
|
imagemagick \
|
|
fonts-noto-cjk \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set up working directory and make it owned by the bun user
|
|
RUN mkdir -p /app/data && chown -R bun:bun /app
|
|
|
|
# Switch to the non-root bun user
|
|
USER bun
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies with exact matching versions extracted from the builder stage
|
|
COPY --chown=bun:bun --from=builder /app/runner-package.json ./package.json
|
|
RUN bun install
|
|
|
|
# Copy build artifacts and prisma config
|
|
COPY --chown=bun:bun --from=builder /app/dist ./
|
|
COPY --chown=bun:bun --from=builder /app/packages/db/prisma ./packages/db/prisma
|
|
COPY --chown=bun:bun --from=builder /app/prisma.config.ts.prod ./prisma.config.ts
|
|
|
|
# Expose port (Bun Hono defaults to 3000)
|
|
EXPOSE 3000
|
|
|
|
# Switch back to root at the end so the container runs the entrypoint as root
|
|
USER root
|
|
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
|
|
# Default command: run migrations and start API server
|
|
CMD ["sh", "-c", "bun prisma migrate deploy && bun index.js"]
|