{"modulePath":"github.com/agentruntimecontrolprotocol/go-sdk","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package server\n\nPackage server hosts ARCP agents. Accept consumes a transport pair and runs one session over it; agents are registered via RegisterAgent / RegisterAgentVersion.\n\n## Types\n\n```go\ntype AgentFunc func(ctx context.Context, input json.RawMessage, jc *JobContext) (any, error)\n```\nAgentFunc is the agent body. The runtime invokes it inside a job; returning (any, nil) produces job.result with the marshalled output, returning a non-nil error produces job.error. To stream results, call jc.StreamResult and return (nil, nil) after the writer is closed.\n\n```go\ntype Job struct {\n\t// contains filtered or unexported fields\n}\n```\nJob is the runtime-side representation of an accepted job.\n\n```go\nfunc (j *Job) Agent() string\n```\nAgent returns the resolved \"name@version\" string.\n\n```go\nfunc (j *Job) ID() string\n```\nID returns the job identifier.\n\n```go\nfunc (j *Job) Lease() arcp.Lease\n```\nLease returns a snapshot of the job's lease.\n\n```go\nfunc (j *Job) Principal() string\n```\nPrincipal returns the submitting principal.\n\n```go\ntype JobContext struct {\n\t// contains filtered or unexported fields\n}\n```\nJobContext is the agent-facing surface inside an AgentFunc. It is the only sanctioned way to emit events, validate lease ops, debit budget counters, and stream chunked results.\n\n```go\nfunc (jc *JobContext) ArtifactRef(uri, contentType string, byteSize uint64, sha256 string)\n```\nArtifactRef emits an \"artifact\\_ref\" event.\n\n```go\nfunc (jc *JobContext) Budget() map[arcp.Currency]float64\n```\nBudget returns a snapshot of remaining per-currency budget.\n\n```go\nfunc (jc *JobContext) Context() context.Context\n```\nContext returns the cancellable context bound to this job's lifecycle.\n\n```go\nfunc (jc *JobContext) JobID() string\n```\nJobID returns the owning job id.\n\n```go\nfunc (jc *JobContext) Lease() arcp.Lease\n```\nLease returns a snapshot of the job's lease grant.\n\n```go\nfunc (jc *JobContext) Log(level slog.Level, msg string, attrs ...slog.Attr)\n```\nLog emits a \"log\" job event.\n\n```go\nfunc (jc *JobContext) Metric(name string, value float64, unit string, dims map[string]string)\n```\nMetric emits a \"metric\" event. If name begins with \"cost.\" and unit matches a budgeted currency, the runtime debits the counter and may emit a follow-up cost.budget.remaining metric.\n\n```go\nfunc (jc *JobContext) Progress(current uint64, total uint64, units, message string)\n```\nProgress emits a \"progress\" event.\n\n```go\nfunc (jc *JobContext) RotateCredential(id, newValue string) error\n```\nRotateCredential updates a stored credential value, emits a submitter status event, and revokes the prior upstream credential.\n\n```go\nfunc (jc *JobContext) SessionID() string\n```\nSessionID returns the owning session id.\n\n```go\nfunc (jc *JobContext) Status(phase, message string)\n```\nStatus emits a \"status\" event.\n\n```go\nfunc (jc *JobContext) StreamResult(encoding string) (io.WriteCloser, error)\n```\nStreamResult opens a writer that emits result\\_chunk events. Close terminates the stream; the runtime emits the final job.result with result\\_id and result\\_size when the AgentFunc returns.\n\n```go\nfunc (jc *JobContext) Thought(text string)\n```\nThought emits a \"thought\" job event.\n\n```go\nfunc (jc *JobContext) ToolCall(tool string, args any) string\n```\nToolCall emits a \"tool\\_call\" event and returns the generated call\\_id the agent should reuse in the matching ToolResult / ToolError.\n\n```go\nfunc (jc *JobContext) ToolError(callID string, err error)\n```\nToolError emits a failed \"tool\\_result\" event.\n\n```go\nfunc (jc *JobContext) ToolResult(callID string, result any)\n```\nToolResult emits a successful \"tool\\_result\" event.\n\n```go\nfunc (jc *JobContext) TraceID() string\n```\nTraceID returns the trace identifier propagated from job.submit.\n\n```go\nfunc (jc *JobContext) ValidateLeaseOp(cap arcp.Capability, target string) error\n```\nValidateLeaseOp checks that (cap, target) is permitted under the lease at the current clock time.\n\n```go\ntype Options struct {\n\t// Name is the runtime's advertised name in session.welcome.\n\tName string\n\t// Version is the runtime's advertised version.\n\tVersion string\n\t// HeartbeatInterval seeds heartbeat_interval_sec in welcome. Zero\n\t// disables heartbeats unless the client negotiates them; default\n\t// is 30s.\n\tHeartbeatInterval time.Duration\n\t// ResumeWindow seeds resume_window_sec; default 600s.\n\tResumeWindow time.Duration\n\t// Verifier authenticates session.hello tokens. nil accepts no\n\t// tokens.\n\tVerifier auth.Verifier\n\t// Logger is the slog.Logger used by the runtime. nil uses\n\t// slog.Default().\n\tLogger *slog.Logger\n\t// Clock is the time source. nil uses clock.Real().\n\tClock clock.Clock\n\t// AckLagThreshold is the number of unacked events that triggers a\n\t// back_pressure status emission. Zero disables.\n\tAckLagThreshold uint64\n\t// Features overrides the advertised feature list. Empty uses the\n\t// SDK default.\n\tFeatures []string\n\t// Provisioner mints lease-bound credentials for accepted jobs. When\n\t// nil, provisioned_credentials is not advertised.\n\tProvisioner credentials.Provisioner\n\t// MaxResultBytes caps a single streamed result. Zero uses 32MiB.\n\tMaxResultBytes int64\n\t// ChunkSize caps an individual result_chunk body. Zero uses 1MiB.\n\tChunkSize int64\n}\n```\nOptions configures a Server.\n\n```go\ntype Server struct {\n\t// contains filtered or unexported fields\n}\n```\nServer is the runtime. Construct with New and call Accept once per session.\n\n```go\nfunc New(opts Options) *Server\n```\nNew returns a Server initialised with opts.\n\n```go\nfunc (s *Server) Accept(ctx context.Context, t transport.Transport) error\n```\nAccept runs one session over t. It blocks until t is closed, ctx is cancelled, or an unrecoverable error fires.\n\n```go\nfunc (s *Server) Close() error\n```\nClose terminates all sessions and active jobs.\n\n```go\nfunc (s *Server) RegisterAgent(name string, fn AgentFunc)\n```\nRegisterAgent registers fn under the bare name.\n\n```go\nfunc (s *Server) RegisterAgentVersion(name, version string, fn AgentFunc)\n```\nRegisterAgentVersion registers fn under name@version.\n\n```go\nfunc (s *Server) SetDefaultAgentVersion(name, version string) error\n```\nSetDefaultAgentVersion records the version returned for bare-name resolution.\n\n","path":"github.com/agentruntimecontrolprotocol/go-sdk/server","name":"server","synopsis":"Package server hosts ARCP agents.","isRedistributable":true}
